<div style="margin:10px">
    <div class="div_form_content">
<h1>User groups management</h1>
    <table>
        <tr>
            <td>
                 Groups list | <a href="index.php?m=administration&a=create_group">Create new group</a>
            </td>
            <td>
                <div style="float:right; margin-right: 150px;">
                    <input type="text" id="search" value="<?=$s?>"/>
                    <input type ="button" value="search" onclick="search()"/>
                </div>
            </td>
        </tr>

    </table>


<table >
   <tr>
       <th>ID</th>
       <th>Group name</th>
       <th>Group Description</th>
       <th>From</th>
       <th>Action</th>
   </tr>
   <?if(count($groups)):?>
   <?foreach($groups as $g):?>
   <tr>
       <td><?=$g['group_id']?></td>
       <td><?=$g['group_name']?></td>
       <td><?=$g['group_description']?></td>
       <td><?=$g['namecustomer']?></td>
       <td><a href="index.php?m=administration&a=permissions&group_id=<?=$g['group_id']?>">Set permissions</a> | 
           <a href="index.php?m=administration&a=edit_group&group_id=<?=$g['group_id']?>">Edit</a> | 
           <a href="index.php?m=administration&a=delete_group&group_id=<?=$g['group_id']?>"onclick="return confirm('Are you sure?')" >Delete</a></td>
   </tr>
   <?endforeach?>
   <?else:?>
   <tr><td colspan="4">No group available, please create one!</td></tr>
   <?endif?>
</table>

<div id="page-number">
    <div id="page-number-left">
        Page 
        <?if($num_pages<=5):?> <!--11111so trang < 5 in tu 1 den 5-->
            <?for($i=1;$i<=$num_pages;$i++):?>
            <span style="border: 1px solid #eee; padding: 5px;<?=$style=($i==$page_num)?'background-color: #ddd':'';?>" class="span_page_number" title="<?=$i?>"><?=$i?></span>
            <?endfor?>
        <?else:?>

            <?if($page_num<5):?> <!--222222222-so trang > 5  neu trang hienj tai <5 in tu 1 den 5-->
				
                <?for($i=1;$i<=5;$i++):?>
                <span style="border: 1px solid #eee; padding: 5px;<?=$style=($i==$page_num)?'background-color: #ddd':'';?>" class="span_page_number" title="<?=$i?>"><?=$i?></span>
                <?endfor?>
                <span style="border: 1px solid #eee; padding: 5px;">...</span>
                <span style="border: 1px solid #eee; padding: 5px;" class="span_page_number" title="<?=$num_pages?>"><?=$num_pages?></span>

            <?else:?> <!--so trang > 5  neu trang hienj tai >= 5 phải kiểm tra lại num_pages-->
                <?if($num_pages>$page_num+4):?>
					<span style="border: 1px solid #eee; padding: 5px;" class="span_page_number" title="1">1</span>
					<span style="border: 1px solid #eee; padding: 5px;">...</span>
                    <?for($i=$page_num-3;$i<=$page_num+3;$i++):?>
                    <span style="border: 1px solid #eee; padding: 5px;<?=$style=($i==$page_num)?'background-color: #ddd':'';?>" class="span_page_number" title="<?=$i?>"><?=$i?></span>
                    <?endfor?>
                    <span style="border: 1px solid #eee; padding: 5px;">...</span>
                    <span style="border: 1px solid #eee; padding: 5px;" class="span_page_number" title="<?=$num_pages?>"><?=$num_pages?></a></span>
                 <?else:?>
					<span style="border: 1px solid #ddd; padding: 5px;" class="span_page_number" title="1">1</span>
					<span style="border: 1px solid #ddd; padding: 5px;">...</span>
                    <?for($i=$page_num-3;$i<=$num_pages;$i++):?>
                    <span style="border: 1px solid #eee; padding: 5px;<?=$style=($i==$page_num)?'background-color: #ddd':'';?>" class="span_page_number" title="<?=$i?>"><?=$i?></span>
                    <?endfor?>
                  <?endif?>
            <?endif?> <!--222222222-so trang > 5  neu trang hienj tai <5 in tu 1 den 5-->
        <?endif?><!--11111so trang < 5 in tu 1 den 5-->

    </div>
</div>
</div>
</div>
<script>
    function search(){
    var word=$('#search').val();
    var url="index.php?m=administration&a=view_group&s="+word;
    window.location=url;
}
</script>
<style>
    table{
        width: 100%;
        margin: 20px;
        
    }
td
{
padding:3px;
}
</style>

